package cn.tedu.qxhouserent.house.pojo.param;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Range;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.time.LocalDate;

@Data
@Accessors(chain = true)
public class AgentAddNewParam implements Serializable {

    @NotEmpty(message = "添加经纪人失败，请填写姓名！")
    @Pattern(regexp = "(^[\\u4e00-\\u9fa5]{2,}(?:·[\\u4e00-\\u9fa5]{2,})*$|^[\\u4e00-\\u9fa5]{2,}$)",
            message = "添加经纪人失败，姓名不合法")
    @ApiModelProperty(value = "姓名",required = true,example = "张三")
    private String name;

    @NotEmpty(message = "添加经纪人失败,请选择性别!")
    @Pattern(regexp = "(男|女)", message = "性别只能为“男”或“女”")
    @ApiModelProperty(value = "性别",required = true)
    private String gender;


    @NotNull(message = "添加经纪人失败,请填写年龄!")
    @Range(min = 18,max = 100,message = "请提交合法的年龄")
    @ApiModelProperty(value = "年龄",required = true)
    private Integer age;
//    @Pattern(regexp = )


    @NotEmpty(message = "添加经纪人失败,请填写身份证!")
    @Pattern(regexp = "(^[1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$)|" +
            "(^[1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}$)",
            message = "身份证号码格式不正确")
    @ApiModelProperty(value = "身份证",required = true)
    private String idCard;

    @NotEmpty(message = "添加经纪人失败,请填写手机号!")
    @Pattern(regexp = "(^1[3-9]\\d{9}$)",
            message = "手机号格式不正确")
    @ApiModelProperty(value = "电话号码",required = true)
    private String phoneNumber;


    @NotEmpty(message = "添加经纪人失败,请填写地址!")
    @ApiModelProperty(value = "家庭住址",required = true)
    private String address;

    @NotNull(message = "添加经纪人失败,必须提交从业时间")
    @ApiModelProperty(value = "从业时间",required = true)
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private LocalDate entryTime;

    @NotNull(message = "必须提交是否启用")
    @Range(min = 0,max = 1,message = "请提交正确的启用信息")
    @ApiModelProperty(value = "是否启用,1为启用,0为不启用",required = true)
    private Integer enable;

}
